package top.xia17.plugins.fast.user.dao.repository;

import top.xia17.plugins.fast.common.database.jpa.extension.Xia17JpaRepository;
import top.xia17.plugins.fast.user.dao.entity.Dept;
import top.xia17.plugins.fast.user.dao.entity.User;

import java.util.Optional;

/**
 * 用户
 *
 * @author xia17
 * @since 2021/7/15 14:05
 */
public interface UserRepository extends Xia17JpaRepository<User, Long> {

    /**
     * find
     * @param username /
     * @return /
     */
    int countAllByUsername(String username);

    /**
     * find
     *
     * @param phone /
     * @return /
     */
    int countAllByPhone(String phone);

    /**
     * find
     *
     * @param email /
     * @return /
     */
    int countAllByEmail(String email);

    /**
     * find
     *
     * @param dept /
     * @return /
     */
    int countAllByDept(Dept dept);


    /**
     * find
     *
     * @param username 用户名
     * @return /
     */
    Optional<User> findByUsername(String username);

    /**
     * 查询通过邮箱
     * @param email /
     * @return /
     */
    Optional<User> findByEmail(String email);
}
